# -*- codeing = utf-8 -*-
# @Time : 2022/3/20 20:04
# @Author : 熊蓓乐
# @File :  test.py
# @Software : PyCharm
import cv2 as cv
import numpy as np
import pytesseract
import gooey
from gooey import Gooey

@Gooey(encodings='utf-8', program_name='老君庙作业区功图分析软件', program_description='技术支持：技术信息室', language='chinese')
def test():
    parser = gooey.GooeyParser(description='GUI')  # 配置名称
    parser.add_argument('油管压力KPa', widget='TextField')  # 文本输入框
    parser.add_argument('套管压力KPa', widget='TextField')  # 文本输入框
    parser.add_argument('泵径mm', widget='TextField')  # 文本输入框
    parser.add_argument('含水率', widget='TextField')  # 文本输入框
    parser.add_argument('选择开始日期', widget='DateChooser')  # 日期选择框
    parser.add_argument('选择结束日期', widget='DateChooser')  # 日期选择框
    parser.add_argument('选择本地文件', widget='FileChooser')  # 文件夹选择框
    args = parser.parse_args()
    pre1=int(args.油管压力KPa)
    pre2=int(args.套管压力KPa)
    redio=int(args.泵径mm)
    water_cut=int(args.含水率)
    data1=args.选择开始日期
    data2=args.选择结束日期
    img_path=args.选择本地文件
    return pre1,pre2,redio,water_cut,data1,data2,img_path

def imge_hot():
    img_arr1 = cv.imread(img_path, 0)[40:150,140:160]
    img_arr2=cv.imread(img_path, 0)[40:150,140:160]

    blue=129
    red=95
    blue_list=[]
    red_list=[]
    for x in range(0,110):
        if(blue in img_arr1[x].tolist()):
            blue_list.append(x)
        if(red in img_arr1[x].tolist()):
            red_list.append(x)
    lenth=max*(np.mean(red_list)-np.mean(blue_list))/110
    return lenth


def resort(pre1,pre2,redio,water_cut,data1,data2,img_path):
    higher=(lenth-0.001*(pre1-pre2)*3.14*0.25*(redio/1000)**2)/(3.14*0.25*(redio/1000)**2*9.8*((100-water_cut)*0.86/100+water_cut/100))
    return higher

if __name__ == '__main__':
    pre1,pre2,redio,water_cut,data1,data2,img_path=test()
    print(pre1,pre2,redio,water_cut,data1,data2,img_path)
    # max=imge_hot()

    # high=resort(pre1,pre2,redio,water_cut,data1,data2,img_path)
    # print(high)